import * as echarts from 'echarts'
const totalFlowColorTable = [
  ['#84f287', '#8af172', '#92f05b', '#9cee3f', '#a8eb12'],
  ['#84f287', '#00d8b9', '#00b6f9', '#0089ff', '#153fec'],
  ['#5a3f89', '#4e3888', '#403188', '#2e2b87', '#0e2587'],
  ['#cbcac8', '#bbb9b8', '#aba9a8', '#9b9999', '#8b898a'],
  ['#90fdf8', '#76e9ea', '#5bd5dd', '#3cc1cf', '#0daec2'],
  ['#e2e4bd', '#bdc09d', '#999d7f', '#777c62', '#575c46'],
  ['#e4d6e7', '#c4b5c7', '#a595a7', '#877688', '#6a596b'],
  ['#adc0de', '#8a9cba', '#697997', '#495876', '#2a3956'],
  ['#f3a775', '#ea905a', '#e07840', '#d65e28', '#cb420e']
]
const totalFlowColors = []
function initTotalFlowColors() {
  for (let i = 0; i < totalFlowColorTable.length; i++) {
    const linearColors = []
    for (let j = 0; j < totalFlowColorTable[i].length; j++) {
      linearColors.push({
        offset: j / totalFlowColorTable[i].length,
        color: totalFlowColorTable[i][j]
      })
    }
    totalFlowColors.push(new echarts.graphic.LinearGradient(0, 0, 1, 1, linearColors))
  }
}
initTotalFlowColors()

function getTotalFlowColor(index) {
  return totalFlowColors[index % totalFlowColors.length]
}

export { getTotalFlowColor }
